package org.yxjme.pickeraddresslibaray;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.telecom.Call;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.airsaid.pickerviewlibrary.ChoiceItemView;
import com.airsaid.pickerviewlibrary.PickerCityUtils;
import com.airsaid.pickerviewlibrary.adapter.NumericWheelAdapter;
import com.airsaid.pickerviewlibrary.adapter.WheelAdapter;
import com.airsaid.pickerviewlibrary.listener.OnItemSelectedListener;
import com.airsaid.pickerviewlibrary.widget.ChoiceHoursMinuteBy12View;
import com.airsaid.pickerviewlibrary.widget.wheelview.WheelView;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.btn_picker).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

//                pick();
//                ChoiceItem();
                new ChoiceHoursMinuteBy12View(MainActivity.this)
                        .setTitle("选择生辰")
                        .setPicker(type,hour,minute)
                        .setCyclic(true)
                        .setTextSize(16)
                        .setOnSelectListener(new ChoiceHoursMinuteBy12View.OnSelectListener() {
                            @Override
                            public void onCitySelect(int type, int hour, int minute) {
                                MainActivity.this.type = type ;
                                MainActivity.this.hour = hour ;
                                MainActivity.this.minute = minute ;
                                StringBuffer stringBuffer = new StringBuffer();
                                stringBuffer.append(type).append("\n");
                                stringBuffer.append(hour).append("\n");
                                stringBuffer.append(minute).append("\n");
                                Toast.makeText(MainActivity.this,stringBuffer.toString(),Toast.LENGTH_SHORT).show();
                            }
                        }).show();
            }
        });
    }



    private int type;
    private int hour;
    private int minute;




    int p ;
    public void ChoiceItem(){
        /*单项选择*/
        ArrayList<String> list = new ArrayList<>() ;
        list.add("的發射點發");
        list.add("的發射點發");
        list.add("的發射點發");
        list.add("的發射點發");
        list.add("的發射點發");
        ChoiceItemView choiceItemView =  new ChoiceItemView(this);
        choiceItemView.setData(list);
        choiceItemView.setOnChoiceSelectListener(new ChoiceItemView.OnChoiceSelectListener() {
            @Override
            public void onChoicesSelect(int option1) {
                p = option1;
                Log.v("[choiceItemView]","[choiceItemView]->option1="+option1);
            }
        });
        choiceItemView.show();
    }




    private void pick() {
        PickerCityUtils pickerCityUtils = new PickerCityUtils(this);
        pickerCityUtils.setOnCitySelectListener(new PickerCityUtils.OnCitySelectListener() {
            @Override
            public void onCitySelect(String str, int option1, int option2, int option3) {

            }

            @Override
            public void onCitySelect(String p, String city, String area) {

            }
        });
        pickerCityUtils.show();
    }
}